#@embedLayout()


#define content()

<form id="formId" method="post">
    <input type="hidden" name="facets.facet_id" id="facetId" value="#(facets.facetId??)">
    <table class="table table-bordered">
        <tr>
            <td style="padding-top:15px;">#(_res.get('facet.form.name')):</td>
            <td><input type="text" id="facetName" name="facets.facet_name"
                       value="#(facets.facet_name??)" style="width: 95%;" #if(facets != null) readonly="readonly" #end>
            </td>
        </tr>
        <tr>
            <td style="padding-top:15px;">#(_res.get('facet.form.type')):</td>
            <td>
                <select name="facets.facet_type" id="facet_type" class="easyui-combobox"
                        data-options="required:true,editable: false"
                        style="width:200px;">

                    #for(dict : dictList)
                        <option value="#(dict.dictName.trim())" #if(facets != null && facets.facet_type == dict.dictName.trim()) selected #end>#(dict.dictName.trim())</option>
                    #end

                </select>
            </td>
        </tr>
        <tr>
            <td style="padding-top:15px;">授权码:</td>
            <td>
                <input type="text" class="easyui-textbox" id="des" name="facets.auth_code" data-options="validType:{length:[0,4000]},multiline:true" value="#(facets.auth_code??)" style="width:98%;height:150px;">
            </td>
        </tr>
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    $(function () {
        $('#facetName').textbox({
            required: true,
            validType: {length: [1, 100]},
            onChange: function (newValue, oldValue) {
                var facetType;
                newValue = newValue.toLowerCase();
                if (newValue.indexOf('ios') === 0) {
                    facetType = 'ios';
                } else if (newValue.indexOf('android') === 0) {
                    facetType = 'android';
                } else {
                    facetType = 'web';
                }
                $('#facet_type').combobox('select', facetType);
            }
        });
    });


    function datagrid_save(opr_type) {
        var url = '';
        if (opr_type == 'add') {
            url = contextRootPath + '/facet/save';
        } else {
            url = contextRootPath + '/facet/update';
        }

        $('#formId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);
                var params = {};
                params.element = _datagrid;
                params.data = data;
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

</script>

#end


